<script>
	function makeAjax(type,url,data,callback,datatype)
	{
		if(!url){
			layer.open({
	            content: '路径参数错误!'
	            ,className: 'popuo-login'
	            ,time: 2
	        })
			
			return false;
		}
		if(!data){
			layer.open({
	            content: '数据参数错误!'
	            ,className: 'popuo-login'
	            ,time: 2
	        })
			return false;
		}
		if(!callback){
			var callback = function(data){
				console.log(data);
			}
		}
		if(!datatype){
			var datatype = 'json';
		}
		if(type == 'get'){
			$.ajax({
				type:'GET',
				url:url,
				data:data,
				success:function(data){
					callback(data);
				},
				dataType:datatype
			});
		}else if(type == 'post'){
			$.ajax({
				type:'POST',
				url:url,
				data:data,
				success:function(data){
					callback(data);
				},
				dataType:datatype
			});
		}
	}

	function sendValidCode(obj,type)
	{
		if(type != 'editpwd')
		{
			if(!send())
			{
				return;
			}
		}
		
		var url = "{SITE_URL}ajax/user.php";

		var data = {};

		data.m = 'send';

		data.phone = $('#phone').val();

		data.type = type;
		
		var callback = function(data)
	    {
	      	showtip(data);
	    };

	    var showtip = function(data)
	    {
	    	if(data.sign == '1')
	    	{
	    		//发送成功,开始倒计时
	    		layer.open({
		            content: data.msg
		            ,className: 'popuo-login'
		            ,skin: 'msg'
		            ,time: 2
		        })
	    		
	    		resetCode();
	    	}
	    	else
	    	{
	    		layer.open({
		            content: data.msg
		            ,className: 'popuo-login'
		            ,skin: 'msg'
		            ,time: 2
		        })
	    	}
	    };


	    makeAjax('post',url,data,callback);
	}

	function regUser()
	{
		if(!checkPhone())
		{
			return;
		}
		var url = "{SITE_URL}ajax/user.php";

		var data = {};

		data.m = 'reg';
		
		data.phone = $('#phone').val();

		data.code = $('#code').val();

		data.pwd = $('#pass1').val();
		
		var callback = function(data)
	    {
	      	showtip(data);
	    };

	    var showtip = function(data)
	    {
	    	if(data.sign == '1')
	      	{
	      		layer.open({
		            content: data.msg
		            ,className: 'popuo-login'
		            ,skin: 'msg'
		            ,time: 2
		            ,end:function(){
		            	//window.location = window.location ;
		            	var url=location.search; 
						if(url.indexOf("?")!=-1){
							//document.title='有参数';
							window.location.href=window.location.href+"&rand="+10000*Math.random();
						}else{
							//document.title='没参数'; 
							window.location.href=window.location.href+"?rand="+10000*Math.random();
						}
		            }
		        })
	      	}
	      	else
	      	{
	      		layer.open({
		            content: data.msg
		            ,className: 'popuo-login'
		            ,skin: 'msg'
		            ,time: 2
		        })
	      	}
	    };


	    makeAjax('post',url,data,callback);
	    init1()
	}
	
	function loginout()
	{
		var url = "{SITE_URL}ajax/user.php";

        var data = {};

        data.m = 'loginout';
        
        var callback = function(data)
        {
            showtip(data);
        };

        var showtip = function(data)
        {
            if(data.sign == '1')
            {
            	layer.open({
		            content: data.msg
		            ,className: 'popuo-login'
		            ,skin: 'msg'
		            ,time: 2
		            ,end:function(){
		            	//window.location = window.location ;
		            	var url=location.search; 
						if(url.indexOf("?")!=-1){
							//document.title='有参数';
							window.location.href=window.location.href+"&rand="+10000*Math.random();
						}else{
							//document.title='没参数'; 
							window.location.href=window.location.href+"?rand="+10000*Math.random();
						}
		            }
		        })
               
            }
            else
            {
            	layer.open({
		            content: data.msg
		            ,className: 'popuo-login'
		            ,skin: 'msg'
		            ,time: 2
		        })
            }
        };
         makeAjax('post',url,data,callback);
	}

    function login()
    {
        var url = "{SITE_URL}ajax/user.php";

        var data = {};

        data.m = 'login';

        data.phone = $('#phone').val();

        data.pwd = $('#pass1').val();
        
        if(!checkPhone())
		{
			return;
		}
        
        
        var callback = function(data)
        {
            showtip(data);
        };

        var showtip = function(data)
        {
            if(data.sign == '1')
            {
            	layer.open({
		            content: data.msg
		            ,className: 'popuo-login'
		            ,skin: 'msg'
		            ,time: 2
		            ,end:function(){
		            	//window.location = window.location ;	            	
		            	var url=location.search; 
						if(url.indexOf("?")!=-1){
							//document.title='有参数';
							window.location.href=window.location.href+"&rand="+10000*Math.random();
						}else{
							//document.title='没参数'; 
							window.location.href=window.location.href+"?rand="+10000*Math.random();
						} 
		            }
		        })
               
            }
            else
            {
            	layer.open({
		            content: data.msg
		            ,className: 'popuo-login'
		            ,skin: 'msg'
		            ,time: 2
		        })
            }
        };


        makeAjax('post',url,data,callback);
        init1()
    }

	function forget()
	{
		if(!checkPhone())
		{
			return;
		}
		
		var url = "{SITE_URL}ajax/user.php";

		var data = {};

		data.m = 'forget';

		data.phone = $('#phone').val();

		data.code = $('#code').val();

		data.pwd = $('#pass1').val();

		data.pwdtoo = $('#pass2').val();
		
		

		var callback = function(data)
	    {
	      	showtip(data);
	      	
	    };

	    var showtip = function(data)
	    {
	      	if(data.sign == '1')
            {
            	layer.open({
		            content: data.msg
		            ,className: 'popuo-login'
		            ,skin: 'msg'
		            ,time: 2
		            ,end:function(){
		            	//window.location = window.location ;
		            	var url=location.search; 
						if(url.indexOf("?")!=-1){
							//document.title='有参数';
							window.location.href=window.location.href+"&rand="+10000*Math.random();
						}else{
							//document.title='没参数'; 
							window.location.href=window.location.href+"?rand="+10000*Math.random();
						}
		            }
		        })
               
            }
            else
            {
            	layer.open({
		            content: data.msg
		            ,className: 'popuo-login'
		            ,skin: 'msg'
		            ,time: 2
		        })
            }
	    };


	    makeAjax('post',url,data,callback);
	    init1()
	}

	function editpwd()
	{
		if(!yzeditpwd())
		{
			return;
		}
		
		
		
		var url = "{SITE_URL}ajax/user.php";

		var data = {};

		data.m = 'editpwd';

		data.code = $('#code').val();

		data.pwd = $('#pass1').val();

		data.pwdtoo = $('#pass2').val();
		
		
		var callback = function(data)
	    {
	      	showtip(data);
	      	if(data.url)
	      	{
	      		window.location = "{$_GET['refresh']}";
	      	}
	    };

	    var showtip = function(data)
	    {
	       if(data.sign == '1')
            {
            	layer.open({
		            content: data.msg
		            ,className: 'popuo-login'
		            ,skin: 'msg'
		            ,time: 2
		            ,end:function(){
		            	//window.location = window.location ;
		            	var url=location.search; 
						if(url.indexOf("?")!=-1){
							//document.title='有参数';
							window.location.href=window.location.href+"&rand="+10000*Math.random();
						}else{
							//document.title='没参数'; 
							window.location.href=window.location.href+"?rand="+10000*Math.random();
						}
		            }
		        })
               
            }
            else
            {
            	layer.open({
		            content: data.msg
		            ,className: 'popuo-login'
		            ,skin: 'msg'
		            ,time: 2
		        })
            }
	    };


	    makeAjax('post',url,data,callback);
	    init1()
	}
	
	function save_number(obj)
	{
		if(!check_zfb(obj))
		{
			return;
		}
		var url = "{SITE_URL}ajax/my.php";

		var data = {};
		
		data.info = new Array();
		
		data.m = 'save_number';
		//支付宝+姓名
		if($('#text_zfb').val() && $('#text_xm').val())
		{
			var temp = {};
			temp.id = $('#zfbid').val();
			temp.number = $('#text_zfb').val();
			temp.name = $('#text_xm').val();
			temp.type = '1';
			temp.institution = '支付宝';
			
			data.info.push(temp);
		}
		else
		{
			var temp = {};
			temp.id = $('#zfbid').val();
			data.info.push(temp);
		}
		
		//银行卡号+开户行+姓名
		if($('#text_bank').val() && $('#text_khh').val() && $('#text_name').val())
		{
			var temp = {};
			temp.id = $('#yhkid').val();
			temp.number = $('#text_bank').val();
			temp.name = $('#text_name').val()
			temp.type = '2';
			temp.institution = $('#text_khh').val();
			
			data.info.push(temp);
		}
		else
		{
			var temp = {};
			temp.id = $('#yhkid').val();
			data.info.push(temp);
		}
		
		if(data.info.length == 0)
		{
			layer.open({
		            content: '请输入完整渠道信息'
		            ,className: 'popuo-login'
		            ,skin: 'msg'
		            ,time: 2
		        })
			return;
		}
		
		var callback = function(data)
	    {
	      	showtip(data);
	    };

	    var showtip = function(data)
	    {
	    	
	    	
	    	if(data.sign == '1')
	    	{
	    		layer.open({
		            content: data.msg
		            ,className: 'popuo-login'
		            ,skin: 'msg'
		            ,time: 2
		            ,end: function () {window.location = '{SITE_URL}index.php?a=my';}
	    		})
	    	}
	    	else
	    	{
	    		layer.open({
		            content: data.msg
		            ,className: 'popuo-login'
		            ,skin: 'msg'
		            ,time: 2
	    		})
	    	}
	      	
	    };


	    makeAjax('post',url,data,callback);
		init1()
	}
	
	function saveApply_fanli(obj,obj1)
	{
		if(!check_spfl(obj))
		{
			return;
		}
		$(obj1).unbind("click"); 
		var url = "{SITE_URL}ajax/my.php";

		var data = {};
		
		data.m = 'saveApply_fanli';
		
		data.chanpin = $('#chanpin').val();
		data.item = $('#item').val();
		data.money = $('#text_xm').val();
		var callback = function(data)
	    {
	      	showtip(data);
	    };

	    var showtip = function(data)
	    {
	    	if(data.sign == '1')
	    	{
	    		layer.open({
		            content: data.msg
		            ,className: 'popuo-login'
		            ,skin: 'msg'
		            ,time: 4
		            ,end: function () {
		            	//window.location = '{SITE_URL}index.php?a=my';
		            	setTimeout(function(){window.location = '{SITE_URL}index.php?a=my';});
		            }
		            
	    		})
	    	}
	    	else
	    	{
	    		layer.open({
		            content: data.msg
		            ,className: 'popuo-login'
		            ,skin: 'msg'
		            ,time: 2
	    		})
	    	}
	    }
		makeAjax('post',url,data,callback);
		init1()
		
    }
	
	
	function getChanpinItem(obj)
	{
		if($(obj).val())
		{
			var url = "{SITE_URL}ajax/my.php";

			var data = {};
			
			data.m = 'getChanpinItem';
			
			data.pid = $(obj).val();
			
			var callback = function(data)
		    {
		      	showtip(data);
		    };
	
		    var showtip = function(data)
		    {
		    	$('#item').empty();
		    	$('#item').append("<option value='"+""+"'>"+"请选择投资项目"+"</option>");
		    	$.each(data.items, function(k,v) {
		    		$('#item').append("<option value='"+v.id+"'>"+v.name+"</option>");
		    	});
		    }
			makeAjax('post',url,data,callback);
		}
	}
	
	function doeditpwd()
	{
		layer.open({
	        type: 1,
	        title: '',
	        style: 'background:#018c47;font-family:微软雅黑;width:90%',
	        content:
	        '<section class="zc">' +
	        '<h3>伏蒙理财</h3>' +
	        '<div class="zc_form">' +
	        '<form><ul class="ulist">' +
	        '<li class="group">' +
	        '<label class="one code" for="code">' +
	        '<input type="text" id="code" class="txt" placeholder="验证码" maxlength="4">' +
	        '<input class="btn btn-small get_code" onclick="sendValidCode(this,\'editpwd\')" type="button" id="J_getCode" value="获取验证码">' +
	        '<button class="btn btn-small reset-code get_code" id="J_resetCode" disabled style="display:none;"><span id="J_second">60</span>秒后重发</button>' +
	        '</label>' +
	        '</li>' +
	        '</li>' +
	        '<li class="group">' +
	        '<label class="one pass">' +
	        '<input class="txt pass2 judge" type="password" id="pass1" onblur="passwordBlur()" placeholder="密码（6-20位字符均可）" maxlength="20"/>' +
	        '<input class="txt" type="text" id="text" style="display:none" onblur="textBlur()" placeholder="密码（6-20位字符均可）" maxlength="20"/>' +
	        '<em  id="togglePassword" onclick="showHidePassword()"></em>' +
	        '</label>' +
	        '</li>' +
	        '<li class="group">' +
	        '<label class="one pass">' +
	        '<input class="txt pass2 judge1" type="password" id="pass2" onblur="passwordBlur()" placeholder="确认密码（6-20位字符均可）" maxlength="20"/>' +
	        '<input class="txt" type="text" id="text1" style="display:none" onblur="textBlur()" placeholder="确认密码（6-20位字符均可）" maxlength="20"/>' +
	        '</label>' +
	        '</li>' +
	        '<submit class="submit" id="reg-next" onclick="editpwd();">修改密码</submit>' +
	        '</ul></form>' +
	        '</div>' +
	        '</section>'
	        ,success: function(elem){
	            $('.layui-m-layerchild').append('<div class="close">X</div>');
	        }
	    });
	}
	
	function wanshan()
	{
		//点击申请返利弹出
		layer.open({
			type: 1
			,shade: 0.8
			,content: '<div class="test">由于您返利账户尚未完善！<br/>请完善后，进行提现操作！</div>'
			,btn: ['现在去','稍后']
				,yes: function(index){
					$('.like').attr({
						href: '{SITE_URL}index.php?a=my&m=account_number'
					});
			}
		});
	}
	
	function fanli()
	{
		//点击申请返利弹出
		layer.open({
			type: 1
			,shade: 0.8
			,content: '<div class="test">由于您个人资料尚未完善！<br/>请完善后，进返利操作！</div>'
			,btn: ['现在去','稍后']
			,yes: function(index){
				$('.like').attr({
					href: '{SITE_URL}index.php?a=my&m=info'
				});
			}
		});
	}


	
	function dologin()
	{
		closeAndNewLayer({
	        type: 1,
	        style: 'background:#018c47;font-family:微软雅黑;width:90%',
	        content: '<section class="zc">' +
	        '<h3>伏蒙理财</h3>' +
	        '<div class="zc_form">' +
	        '<form><ul class="ulist">' +
	        '<li class="group">' +
	        '<label class="one" for="phone">' +
	        '<input type="text" id="phone" class="txt" placeholder="手机号" maxlength="11">' +
	        '<a href="javascript:;" onclick="textclean()">  </a>' +
	        '</label>' +
	        '</li>' +
	        '<li class="group">' +
	        '<label class="one">' +
	        '<input class="txt judge" type="password" id="pass1" onblur="passwordBlur()" placeholder="密码（6-20位字符均可）" maxlength="20"/>' +
	        '<input class="txt" type="text" id="text" style="display:none" onblur="textBlur()" placeholder="密码（6-20位字符均可）" maxlength="20"/>' +
	        '<em  id="togglePassword" onclick="showHidePassword()"></em>' +
	        '</label>' +
	        '</li>' +
	        '<submit class="submit" id="reg-next" onclick="login()">登 录</submit>' +
	        '</ul></form>' +
	        '<span class="yd"><a style="float:left;" href="javascript:;" class="forget">找回密码？</a><a href="javascript:;" class="register" >注册</a></span></div></div>' +
	        '</section>',
	        success: function(elem){
	            $('.layui-m-layerchild').append('<div class="close">X</div>');
	        }
	    })
	}
	
	
	
	function saveApply_tixian(obj,obj1)
	{
		if(!check_sptx(obj))
		{
			return;
		}
		
		$(obj1).unbind("click"); 
		
		var url = "{SITE_URL}ajax/my.php";

		var data = {};
		
		data.m = 'saveApply_tixian';
		
		data.money = $('#text_je').val();
		var callback = function(data)
	    {
	      	showtip(data);
	    };

	    var showtip = function(data)
	    {
	    	if(data.sign == '1')
	    	{
	    		layer.open({
		            content: data.msg
		            ,className: 'popuo-login'
		            ,skin: 'msg'
		            ,time: 2
		            ,end: function () {window.location = '{SITE_URL}index.php?a=my';}
	    		})
	    	}
	    	else
	    	{
	    		layer.open({
		            content: data.msg
		            ,className: 'popuo-login'
		            ,skin: 'msg'
		            ,time: 2
	    		})
	    	}
	    }
		
		makeAjax('post',url,data,callback);
		init1()

	}
	
	function saveuserinfo(obj)
	{
		if(!check(obj))
		{
			return;
		}
		
		var url = "{SITE_URL}ajax/my.php";
		
		var data = $('#userinfo').serialize();
		
		var callback = function(data)
	    {
	      	showtip(data);
	    };

	    var showtip = function(data)
	    {
	    	if(data.sign == '1')
	    	{
	    		layer.open({
		            content: data.msg
		            ,className: 'popuo-login'
		            ,skin: 'msg'
		            ,time: 2
		            ,end: function () {window.location = '{SITE_URL}index.php?a=my';}
	    		})
	    	}
	    	else
	    	{
	    		layer.open({
		            content: data.msg
		            ,className: 'popuo-login'
		            ,skin: 'msg'
		            ,time: 2
	    		})
	    	}
	    }
		makeAjax('post',url,data,callback);
		init1()
	}	
    
function init1(){    	
    document.getElementById('submit1').disabled=true;
	setTimeout(function (){
    document.getElementById('submit1').disabled=false;
    },5000);    	
}     

	

</script>